package com.clkj.sunhelp.adapter.list;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.clkj.sunhelp.R;
import com.clkj.sunhelp.bean.PublicityOfApplyObjItem;

import java.util.List;

/**
 * 申请对象公示列表adapter
 * Created by Administrator on 2017/3/27.
 */

public class ListAdapterForPublicityOfApplyObj extends BaseAdapter {


    List<PublicityOfApplyObjItem> mPublicityList;
    Context mContext;
    LayoutInflater mLayoutInflater;

    public ListAdapterForPublicityOfApplyObj(Context context, List<PublicityOfApplyObjItem> publicityList) {
        mContext = context;
        this.mPublicityList = publicityList;
        mLayoutInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return mPublicityList.size();
    }

    @Override
    public Object getItem(int i) {
        return mPublicityList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {

        ViewHolder viewHolder = null;
        if (view == null) {
            view = mLayoutInflater.inflate(R.layout.list_item_publicity_apply_obj, null);
            viewHolder = new ViewHolder();
            viewHolder.tvPublicityTitle = (TextView) view.findViewById(R.id.tv_publicity_title);
            viewHolder.tvPublicityTime = (TextView) view.findViewById(R.id.tv_publicity_time);


            view.setTag(viewHolder);

        } else {
            viewHolder = (ViewHolder) view.getTag();
        }

        viewHolder.tvPublicityTitle.setText(mPublicityList.get(i).getName());
        viewHolder.tvPublicityTime.setText("公示时间:"+mPublicityList.get(i).getBegintime()+"到"+mPublicityList.get(i).getEndtime());


        return view;
    }


    static class ViewHolder {
        private TextView tvPublicityTitle;
        private TextView tvPublicityTime;


    }
}

